//
//  JLHomeViewController.m
//  JLStyleApp
//
//  Created by LvJianfeng on 15/8/21.
//  Copyright (c) 2015年 JLStyle. All rights reserved.
//

#import "JLHomeViewController.h"
#import "JLEditModuleListTableViewController.h"

@interface JLHomeViewController ()
@property (strong, nonatomic) UIScrollView * scrollview;

@property (weak, nonatomic) UIView *jobView;
//界面元素
@property (weak, nonatomic) UIImageView *avatarImageView;
@property (weak, nonatomic) UIImageView *sexImageView;
@property (weak, nonatomic) UIImageView *qrCodeImageView;
@property (weak, nonatomic) UILabel *nameLabel;
@property (weak, nonatomic) UILabel *xueliLabel;
@property (weak, nonatomic) UILabel *schoolLabel;
@property (weak, nonatomic) UILabel *professionalLabel;
@end

@implementation JLHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //self.title = @"简历·风";
    
    
    [self.view addSubview:self.scrollview];
    
    //界面
    [self setupTopPersonMessageView];
    
    [self setupMenuView];
}

- (void)viewWillAppear:(BOOL)animated{
    self.view.backgroundColor = [UIColor customControllerBackgroundColor];
}

//创建个人信息界面
- (void)setupTopPersonMessageView{
    UIView *messageBackView = [[UIView alloc] init];
    messageBackView.backgroundColor = GlobalColor;
    messageBackView.frame = CGRectMake(0, 0, ScreenWidth, 164);
    [self.scrollview addSubview:messageBackView];
    
//    @property (weak, nonatomic) UIImageView *avatarImageView;
    UIImageView *avatarImageView = [[UIImageView alloc] init];
    avatarImageView.image = [UIImage imageNamed:@"avatar.jpg"];
    avatarImageView.frame = CGRectMake(((ScreenWidth/2)-140)/2, 164/2-70, 140, 140);
    avatarImageView.layer.masksToBounds = YES;
    avatarImageView.layer.cornerRadius = 70;
    avatarImageView.layer.borderWidth = 5;
    avatarImageView.layer.borderColor = [UIColor whiteColor].CGColor;
    [messageBackView addSubview:avatarImageView];
    
//    @property (weak, nonatomic) UILabel *nameLabel;
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @"测试排版";//@"";
    nameLabel.font = JLFont(24);
    nameLabel.textColor = [UIColor whiteColor];
    nameLabel.frame = CGRectMake(ScreenWidth/2+15, avatarImageView.center.y-60, ScreenWidth/2-15, 30);
    [messageBackView addSubview:nameLabel];
//    @property (weak, nonatomic) UIImageView *sexImageView;
//    @property (weak, nonatomic) UIImageView *qrCodeImageView;

//    @property (weak, nonatomic) UILabel *xueliLabel;
    UILabel *xueliLabel = [[UILabel alloc] init];
    xueliLabel.text = @"测试排版";//@"本科";
    xueliLabel.font = JLFont(15);
    xueliLabel.textColor = [UIColor whiteColor];
    xueliLabel.frame = CGRectMake(ScreenWidth/2+15, nameLabel.center.y+30, ScreenWidth/2-15, 30);
    [messageBackView addSubview:xueliLabel];
//    @property (weak, nonatomic) UILabel *schoolLabel;
    UILabel *schoolLabel = [[UILabel alloc] init];
    schoolLabel.text = @"测试排版";//@"北京大学";
    schoolLabel.font = JLFont(15);
    schoolLabel.textColor = [UIColor whiteColor];
    schoolLabel.frame = CGRectMake(ScreenWidth/2+15, xueliLabel.center.y+10, ScreenWidth/2-15, 30);
    [messageBackView addSubview:schoolLabel];
//    @property (weak, nonatomic) UILabel *professionalLabel;
    UILabel *professionalLabel = [[UILabel alloc] init];
    professionalLabel.text = @"测试排版";//@"软件开发";
    professionalLabel.font = JLFont(15);
    professionalLabel.textColor = [UIColor whiteColor];
    professionalLabel.frame = CGRectMake(ScreenWidth/2+15, schoolLabel.center.y+10, ScreenWidth/2-15, 30);
    [messageBackView addSubview:professionalLabel];
    
    UIView *jobBackView = [[UIView alloc] init];
    jobBackView.backgroundColor = GlobalColor;
    jobBackView.frame = CGRectMake(0, messageBackView.center.y+82, ScreenWidth, 80);
    [self.scrollview addSubview:jobBackView];
    
    UILabel *tipLabel = [[UILabel alloc] init];
    tipLabel.text = @"测试排版";//@"求职意向:";
    tipLabel.font = JLFont(16);
    tipLabel.textColor = [UIColor whiteColor];
    tipLabel.frame = CGRectMake(15, 0, 80, 15);
    [jobBackView addSubview:tipLabel];
    
    NSString *job = @"测试排版";//@"iOS高级开发工程师/iOS开发工程师/PHP开发工程师";
    UIFont *jobFont = JLFont(20);
    CGSize jobSize = [JFGlobalInstance sizeWithString:job font:jobFont maxSize:CGSizeMake(ScreenWidth-30, 200)];
    UILabel *jobLabel = [[UILabel alloc] init];
    jobLabel.text = job;
    jobLabel.numberOfLines = 0;
    jobLabel.font = jobFont;
    jobLabel.textColor = [UIColor whiteColor];
    jobLabel.frame = CGRectMake(15, tipLabel.center.y+15, jobSize.width, jobSize.height);
    [jobBackView addSubview:jobLabel];
    
    jobBackView.frame = CGRectMake(0, messageBackView.center.y+82, ScreenWidth, tipLabel.center.y+15+jobSize.height+15);
    NSLog(@"--%f",jobBackView.bounds.size.height);
    self.jobView = jobBackView;
}

//创建菜单布局
- (void)setupMenuView{
    CGFloat menuHeight = ScreenHeight - (self.jobView.center.y + self.jobView.bounds.size.height / 2) - 64;
    NSLog(@"menuHeight：%f-%f--%f",ScreenHeight,menuHeight,self.jobView.bounds.size.height);
    UIView *menuView = [[UIView alloc] initWithFrame:CGRectMake(0,self.jobView.center.y + self.jobView.bounds.size.height / 2, ScreenWidth, menuHeight)];
    //
    menuView.backgroundColor = [UIColor redColor];
    [self.scrollview addSubview:menuView];
    
//    [menuView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.width.mas_equalTo(ScreenWidth);
//        make.top.mas_equalTo(self.jobView.center.y + self.jobView.bounds.size.height / 2);
//        make.bottom.equalTo(self.scrollview.mas_bottom);
//    }];
    
    UIView *myResumeView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth/2+20, menuHeight*0.4)];
    myResumeView.backgroundColor = [UIColor colorWithHexString:@"#EC7A3B"];
    [menuView addSubview:myResumeView];
    
    UIView *createResumeView = [[UIView alloc] initWithFrame:CGRectMake(0, menuHeight*0.4, ScreenWidth/2+20, menuHeight*0.4)];
    createResumeView.backgroundColor = [UIColor colorWithHexString:@"#2FB8E5"];
    [menuView addSubview:createResumeView];
    UITapGestureRecognizer *createResumeGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapCreateResumeViewAction:)];
    [createResumeView addGestureRecognizer:createResumeGestureRecognizer];
    
    UIView *editResumeView = [[UIView alloc] initWithFrame:CGRectMake(0, menuHeight*0.8, ScreenWidth/2+20, menuHeight*0.2)];
    editResumeView.backgroundColor = [UIColor colorWithHexString:@"#F4FA9A"];
    [menuView addSubview:editResumeView];
    
    //附近求职者
    UIView *nearbyResumeView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth/2+20, 0, ScreenWidth/2-20, menuHeight*0.3)];
    nearbyResumeView.backgroundColor = [UIColor colorWithHexString:@"#FDBB4A"];
    [menuView addSubview:nearbyResumeView];
    UITapGestureRecognizer *nearbyGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapNearbyViewAction:)];
    [nearbyResumeView addGestureRecognizer:nearbyGestureRecognizer];
    
    UIView *shareResumeView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth/2+20, menuHeight*0.3, ScreenWidth/2-20, menuHeight*0.3)];
    shareResumeView.backgroundColor = [UIColor colorWithHexString:@"#68CC93"];
    [menuView addSubview:shareResumeView];
    
    UIView *settingResumeView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth/2+20, menuHeight*0.6, ScreenWidth/2-20, menuHeight*0.2)];
    settingResumeView.backgroundColor = [UIColor colorWithHexString:@"#629E82"];
    [menuView addSubview:settingResumeView];
    
    UIView *qrcodeResumeView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth/2+20, menuHeight*0.8, ScreenWidth/2-20, menuHeight*0.2)];
    qrcodeResumeView.backgroundColor = [UIColor colorWithHexString:@"#1E96BE"];
    [menuView addSubview:qrcodeResumeView];
}

//action
- (void)tapCreateResumeViewAction:(UITapGestureRecognizer *)tap{
    JLEditModuleListTableViewController *editModuleListVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:NSStringFromClass([JLEditModuleListTableViewController class])];
    [self.navigationController pushViewController:editModuleListVC animated:YES];
}

- (void)tapNearbyViewAction:(UITapGestureRecognizer *)tap{
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


#pragma mark lazyload
- (UIScrollView *)scrollview{
    if (_scrollview==nil) {
        _scrollview = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    }
    return _scrollview;
}
@end
